/**
 * Copyright (c) 2006, PORTALIER Julien
 * 
 * Licensed under The LGPL License
 * Redistributions of files must retain the above copyright notice.
 * 
 * Builder is inspired by Dombuilder, Copyright (c) 2006 Dan Webb
 * 
 * @package    Feather-CM
 * @subpackage Javascript
 * @copyright  Copyright (c) 2006, Julien PORTALIER
 * @link       http://portalier.com/feather
 * @license    http://www.opensource.org/licenses/lgpl-license.php The LGPL License
 */

Element.extend(
{
	// display
	
	visible: function()
	{
		return (this.getStyle('display') != 'none');
	},
	
	show: function(type)
	{
		return this.setStyle('display', type || 'block');
	},
	
	hide: function()
	{
		return this.show('none');
	},
	
	toggle: function()
	{
		return this.visible() ? this.hide() : this.show();
	},
	
	// DOM
	
	isChildOf: function(par)
	{
		var el = this;
		if (el == par)
			return false;
		
		while (el != par && el.getParent)
			el = el.getParent();
		
		return (el == par);
	},
	
	getText: function(name, index)
	{
		var node = name ? $ES(name, node)[index || 0] : this;
		if (node)
		{
			if (node.childNodes.length > 1) {
				return node.childNodes[1].nodeValue;
			}
			else if (node.childNodes.length > 0) {
				return node.firstChild.nodeValue;
			}
		}
		return '';
	}
});